﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using PocketMahjong.Core;

namespace PocketMahjong
{
	public partial class ConfigForm : Form
	{
		public ConfigForm()
		{
			InitializeComponent();

			if (Config.Instance.IsRandom)
				_random.Checked = true;
			else
				_solvable.Checked = true;

			var arr = LayoutProvider.Layouts;
			_layout.DataSource = arr;
			_layout.SelectedValue = Config.Instance.Layout;
		}

		protected override void OnClosing(CancelEventArgs e)
		{
			Config.Instance.IsRandom = _random.Checked;
			Config.Instance.Layout = (string)_layout.SelectedValue;
			Config.Save();
		}

		private void _layout_SelectedIndexChanged(object sender, EventArgs e)
		{
			_view.Layout = (Layout)_layout.SelectedItem;
		}
	}
}